<?php
//------------------------------------------------------------------------------------------------------------------------------
//	Nom : about.php
//	Auteurs: Defondemieres Fabrice - Delfour Kevin
//	Description :
//------------------------------------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------------------------------------
//Fonctions et variables
//------------------------------------------------------------------------------------------------------------------------------
include ('php/Lib_Liste.php');

// ini_set("error_reporting", E_ALL);
// ini_set("display_errors","1"); 
// ini_set("ignore_repeated_errors","1");
// ini_set("log_errors", "1" ); 
// ini_set("error_log", "errors/errors_php_about.txt" ); 

	function liste($chemin)
	{  
	   $back = "<a href='Javascript:history.go(-1)'><img src='icon/back.jpg' border='0'/></a>";
	   $nbFile = 0;
	   $nbRep = 0;
	   $Echo = "";
	   $Echo.="<div id='contentfolder'>$back&nbsp;<b>Repertoire.$chemin.</b><br/>";
	   $nom_repertoire = $chemin;
	   $pointeur = opendir($nom_repertoire);
	   while ($fichier = readdir($pointeur)){
	      if(($fichier != '.') && ($fichier != '..')){
	         if (is_dir($nom_repertoire.'/'.$fichier)){
	             $Echo.=liste($nom_repertoire.'/'.$fichier);
      				if ($nbRep % 5 == 0) {
      						$Echo.="<br/>";
      				}
      				
      				$nbRep = $nbRep + 1;
	         }
	         else{
			 $Extension = decapsuler($fichier);
				$Echo.="<div id='blockfile'>";
				if ($nbFile % 5 == 0) {
						$Echo.="<br/>";
				}
				$Echo.="<span style='margin-left:30px;'><a href='$nom_repertoire/$fichier'><img src='icon/files.jpg' border='0'/><font color='#FF0099'>$fichier</font></a> - Fichier:$Extension </span>";
				$Echo.="</div>";
				$nbFile = $nbFile + 1;
	         }
	      }
	   }
	   if ($nbFile == 0) {
			$Echo.="<br/>$nbRep repertoires</hr></div>";
	   }
	   else {
			$Echo.="Nombre de fichiers : $nbFile</hr></div>";
	   }
	   closedir($pointeur);
	   return $Echo;
	}

	function decapsuler($nomfichier)
	{
		$Rest = substr($nomfichier,-3);
		switch (strtolower($Rest)) {
			case "gif":
			case "jpg":
			case "jpeg":
			case "bmp":	{return "Image";}
			case "pdf":	{return "Pdf";}
			case ".ps":	{return "PostScript";}
			case "txt":	{return "Texte";}
			case "doc":	{return "Word 97";}
			case "ocx":{return "Word 2007";}
			case "ppt":	{return "Powerpoint 97";}
			case "ptx":{return "Powerpoint 2007";}
			case "rar":	
			case "r.gz":	
			case "tar":	
			case "zip":	{return "Archive";}
			case "exe":	{return "Executable";}
			
			break;
		}
	}

	$Echo = liste('.');
  $Echo_left = "";

include('template/top.tpl');
include('template/main.tpl');
include('template/back.tpl');
?>
